/*
 * GuudThread.cpp
 *
 *  Created on: 2013-1-19
 *      Author: heqiu
 */
#include "GuudThread.h"

namespace guud {

GuudThread::GuudThread() {
	m_init_flag = 0;
	m_thread = NULL;
}

GuudThread::~GuudThread() {
}

void GuudThread::start() {
	if (m_init_flag == 1) {
		return;
	}
	m_init_flag = 1;
	m_thread = SDL_CreateThread((int (*)(void*))Guud_ThreadFunc, this);
}

int Guud_ThreadFunc(void * param) {
	GuudThread * threadPtr = (GuudThread *) param;
	threadPtr->run();
	return 0;
}

void GuudThread::wait() {
	SDL_WaitThread(m_thread, NULL);
}

}

